/*
XPTracker - Alternative Agile Tracking Tool
Copyright (C) 2006-2009  Stephen Starkey

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/
package org.xptracker.domain;

import org.hibernate.annotations.Proxy;
import org.xptracker.persistence.Identified;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.util.Date;

@Entity
@Table(name = "story_desc_snapshot")
@Proxy(lazy = false)
public class StoryDescriptionSnapshot extends Identified {
  private String storyId;
  private Date occurred = new Date();
  private String summary;
  private String description;
  private String author;

  protected StoryDescriptionSnapshot() {
  }

  public StoryDescriptionSnapshot(Story story, User author) {
    this.storyId = story.getId();
    this.summary = story.getSummary();
    this.description = story.getDescription();
    this.author = author == null ? null : author.getUsername();
  }

  @Column(name = "story_id")
  public String getStoryId() {
    return storyId;
  }

  public void setStoryId(String storyId) {
    this.storyId = storyId;
  }

  public Date getOccurred() {
    return occurred;
  }

  public void setOccurred(Date occurred) {
    this.occurred = occurred;
  }

  public String getSummary() {
    return summary;
  }

  public void setSummary(String summary) {
    this.summary = summary;
  }

  @Lob
  @Column(length = 65535)
  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getAuthor() {
    return author;
  }

  public void setAuthor(String author) {
    this.author = author;
  }
}
